# Maintainer: Rafał Brzegowy <rafal.brzegowy@yahoo.com>

_realname=libexodus
_releases=2021-01-20
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=8.09
pkgrel=1
pkgdesc="EXODUS is a model developed to store and retrieve data for finite element analyses (mingw-w64)"
arch=('any')
depends=("${MINGW_PACKAGE_PREFIX}-crt")
makedepends=("unzip"
             "${MINGW_PACKAGE_PREFIX}-netcdf")
url="https://gsjaardema.github.io/seacas/"
license=('BSD')
source=("https://github.com/gsjaardema/seacas/archive/v${_releases}.zip")
sha256sums=('6FF7C3F0651138F2E2305B5270108CA45F96346A739B35A126A0A260C91CBE64')
noextract=("v${_releases}.zip") # bsdtar could not unpack this archive

prepare() {  
  rm -rf "${srcdir}/seacas-${_releases}"
  unzip -oq v${_releases}.zip -d ${srcdir}
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"
  
  make -f Makefile.standalone -C "${srcdir}/seacas-${_releases}/packages/seacas/libraries/exodus"
}

package() {
  mkdir -p ${pkgdir}${MINGW_PREFIX}/{lib,include/exodus,include/sierra}
  cd "${srcdir}/seacas-${_releases}/packages/seacas/libraries/exodus/include"
	install -Dm644 *.h "${pkgdir}${MINGW_PREFIX}/include/exodus"
  cd "${srcdir}/seacas-${_releases}/packages/seacas/libraries/exodus/sierra"
	install -Dm644 *.h "${pkgdir}${MINGW_PREFIX}/include/sierra"
  cd "${srcdir}/seacas-${_releases}/packages/seacas/libraries/exodus"
	install -Dm644 lib*.a "${pkgdir}${MINGW_PREFIX}/lib"
  install -Dm644 "${srcdir}/seacas-${_releases}/packages/seacas/libraries/exodus"/COPYRIGHT ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
